package c.e.a.b.f.b;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.text.TextUtils;
import b.i.b.f;
import c.e.a.b.b.k.b;
import c.e.a.b.e.c.q8;
import c.e.a.b.e.c.qa;
import c.e.a.b.e.c.ra;
import com.huawei.agconnect.exception.AGCServerException;
import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import java.lang.reflect.InvocationTargetException;

/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class c extends s5 {
    public Boolean b;
    public e c = b.a;
    public Boolean d;

    public c(u4 u4Var) {
        super(u4Var);
    }

    public static long B() {
        return ((Long) p.D.a(null)).longValue();
    }

    public final boolean A(String str) {
        return "1".equals(this.c.c(str, "measurement.event_sampling_enabled"));
    }

    public final boolean C() {
        if (this.b == null) {
            Boolean w = w("app_measurement_lite");
            this.b = w;
            if (w == null) {
                this.b = Boolean.FALSE;
            }
        }
        return this.b.booleanValue() || !this.a.e;
    }

    public final Bundle D() {
        try {
            if (this.a.a.getPackageManager() == null) {
                d().f.a("Failed to load metadata: PackageManager is null");
                return null;
            }
            ApplicationInfo a = b.a(this.a.a).a(this.a.a.getPackageName(), AesLen.ROOTKEY_COMPONET_LEN);
            if (a != null) {
                return a.metaData;
            }
            d().f.a("Failed to load metadata: ApplicationInfo is null");
            return null;
        } catch (NameNotFoundException e) {
            d().f.b("Failed to load metadata: Package name not found", e);
            return null;
        }
    }

    public final String c(String str, String str2) {
        Class cls = String.class;
        try {
            return (String) Class.forName("android.os.SystemProperties").getMethod("get", new Class[]{cls, cls}).invoke(null, new Object[]{str, str2});
        } catch (ClassNotFoundException e) {
            d().f.b("Could not find SystemProperties class", e);
            return str2;
        } catch (NoSuchMethodException e2) {
            d().f.b("Could not find SystemProperties.get() method", e2);
            return str2;
        } catch (IllegalAccessException e3) {
            d().f.b("Could not access SystemProperties.get()", e3);
            return str2;
        } catch (InvocationTargetException e4) {
            d().f.b("SystemProperties.get() threw an exception", e4);
            return str2;
        }
    }

    public final int m(String str) {
        return Math.max(Math.min(q(str, p.I), 100), 25);
    }

    public final long n(String str, j3<Long> j3Var) {
        if (str == null) {
            return ((Long) j3Var.a(null)).longValue();
        }
        str = this.c.c(str, j3Var.a);
        if (TextUtils.isEmpty(str)) {
            return ((Long) j3Var.a(null)).longValue();
        }
        try {
            return ((Long) j3Var.a(Long.valueOf(Long.parseLong(str)))).longValue();
        } catch (NumberFormatException unused) {
            return ((Long) j3Var.a(null)).longValue();
        }
    }

    public final boolean o(j3<Boolean> j3Var) {
        return u(null, j3Var);
    }

    public final int p(String str) {
        if (q8.a() && u(null, p.w0)) {
            return Math.max(Math.min(q(str, p.H), 2000), AGCServerException.UNKNOW_EXCEPTION);
        }
        return AGCServerException.UNKNOW_EXCEPTION;
    }

    public final int q(String str, j3<Integer> j3Var) {
        if (str == null) {
            return ((Integer) j3Var.a(null)).intValue();
        }
        str = this.c.c(str, j3Var.a);
        if (TextUtils.isEmpty(str)) {
            return ((Integer) j3Var.a(null)).intValue();
        }
        try {
            return ((Integer) j3Var.a(Integer.valueOf(Integer.parseInt(str)))).intValue();
        } catch (NumberFormatException unused) {
            return ((Integer) j3Var.a(null)).intValue();
        }
    }

    public final double r(String str, j3<Double> j3Var) {
        if (str == null) {
            return ((Double) j3Var.a(null)).doubleValue();
        }
        str = this.c.c(str, j3Var.a);
        if (TextUtils.isEmpty(str)) {
            return ((Double) j3Var.a(null)).doubleValue();
        }
        try {
            return ((Double) j3Var.a(Double.valueOf(Double.parseDouble(str)))).doubleValue();
        } catch (NumberFormatException unused) {
            return ((Double) j3Var.a(null)).doubleValue();
        }
    }

    public final int s(String str) {
        return q(str, p.o);
    }

    public final int t() {
        if (q8.a() && this.a.g.u(null, p.x0)) {
            t9 k = k();
            Boolean bool = k.a.x().e;
            Object obj = (k.y0() >= 201500 || !(bool == null || bool.booleanValue())) ? 1 : null;
            if (obj != null) {
                return 100;
            }
        }
        return 25;
    }

    public final boolean u(String str, j3<Boolean> j3Var) {
        if (str == null) {
            return ((Boolean) j3Var.a(null)).booleanValue();
        }
        str = this.c.c(str, j3Var.a);
        if (TextUtils.isEmpty(str)) {
            return ((Boolean) j3Var.a(null)).booleanValue();
        }
        return ((Boolean) j3Var.a(Boolean.valueOf(Boolean.parseBoolean(str)))).booleanValue();
    }

    public final boolean v(String str, j3<Boolean> j3Var) {
        return u(str, j3Var);
    }

    public final Boolean w(String str) {
        f.N(str);
        Bundle D = D();
        if (D == null) {
            d().f.a("Failed to load metadata: Metadata bundle is null");
            return null;
        } else if (D.containsKey(str)) {
            return Boolean.valueOf(D.getBoolean(str));
        } else {
            return null;
        }
    }

    public final boolean x() {
        Boolean w = w("firebase_analytics_collection_deactivated");
        return w != null && w.booleanValue();
    }

    public final Boolean y() {
        Boolean w = w("google_analytics_adid_collection_enabled");
        boolean z = w == null || w.booleanValue();
        return Boolean.valueOf(z);
    }

    public final Boolean z() {
        if (!((qa) ra.b.q()).q() || !o(p.u0)) {
            return Boolean.TRUE;
        }
        Boolean w = w("google_analytics_automatic_screen_reporting_enabled");
        boolean z = w == null || w.booleanValue();
        return Boolean.valueOf(z);
    }
}
